/*
 * WalletAccount.java
 * 
 * Created on 19-jun-2007, 20:51:27
 * 
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.i2a.peacsy.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Tortuga
 */
@Entity
@Table(name = "TA_WALL_WALLET_ACCOUNTS")
@NamedQueries({@NamedQuery(name = "WalletAccount.findByAccoCoCode", query = "SELECT w FROM WalletAccount w WHERE w.accoCoCode = :accoCoCode")})
public class WalletAccount implements Serializable {

  @Id
  @Column(name = "ACCO_CO_CODE", nullable = false)
  private Integer accoCoCode;

  @JoinColumn(name = "PERS_CO_CODE", referencedColumnName = "PERS_CO_CODE")
  @ManyToOne
  private Person persCoCode;

  @JoinColumn(name = "SHAR_CO_CODE", referencedColumnName = "ACCO_CO_CODE")
  @ManyToOne
  private SharedAccount sharCoCode;

  @OneToMany(mappedBy = "wallCoCode")
  private Collection<Movement> movementCollection;
    protected static org.apache.commons.logging.Log
        log = org.apache.commons.logging.LogFactory.getLog(WalletAccount.class);

    public WalletAccount() {
    }

  public WalletAccount(Integer accoCoCode) {
    this.accoCoCode = accoCoCode;
  }

  public Integer getAccoCoCode() {
    return accoCoCode;
  }

  public void setAccoCoCode(Integer accoCoCode) {
    this.accoCoCode = accoCoCode;
  }

  public Person getPersCoCode() {
    return persCoCode;
  }

  public void setPersCoCode(Person persCoCode) {
    this.persCoCode = persCoCode;
  }

  public SharedAccount getSharCoCode() {
    return sharCoCode;
  }

  public void setSharCoCode(SharedAccount sharCoCode) {
    this.sharCoCode = sharCoCode;
  }

  public Collection<Movement> getMovementCollection() {
    return movementCollection;
  }

  public void setMovementCollection(Collection<Movement> movementCollection) {
    this.movementCollection = movementCollection;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (accoCoCode != null ? accoCoCode.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof WalletAccount)) {
      return false;
    }
    WalletAccount other = (WalletAccount) object;
    if (this.accoCoCode != other.accoCoCode && (this.accoCoCode == null || !this.accoCoCode.equals(other.accoCoCode))) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "org.i2a.peacsy.entity.WalletAccount[accoCoCode=" + accoCoCode + "]";
  }

}
